<%@page import="com.bss.beans.DailyRevenue"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@page import="java.text.SimpleDateFormat" %>
<%@page import="java.text.DateFormat" %>
<%@page import="java.util.Calendar"%>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>DAILY ACCOUNT REPORT</title>
 <!-- calendar stylesheet -->
  <link rel="stylesheet" type="text/css" media="all" href="calendar-win2k-cold-1.css" title="win2k-cold-1" />
  
  <link rel="stylesheet" href="style.css" type="text/css">


  
  <!-- main calendar program -->
  <script type="text/javascript" src="calendar.js"></script>

  <!-- language for the calendar -->
  <script type="text/javascript" src="lang/calendar-en.js"></script>

  <!-- the following script defines the Calendar.setup helper function, which makes
       adding a calendar a matter of 1 or 2 lines of code. -->
  <script type="text/javascript" src="calendar-setup.js"></script>
 <script language="JavaScript" type="text/JavaScript" src="java/javascript.js"></script>
<SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript" SRC="java/base.js"></SCRIPT>
<script language="JavaScript" src="java/tabel.js" type="text/javascript"></script>
<script language="javascript" SRC="java/JS/validation.js" TYPE="text/javascript"></script>
<script language="javascript">


	function ajaxGet(strURL, inputArgs, successFunc) {
	    var xmlHttpReq = false;
	    var self = this;
	    
	    // Mozilla/Safari
	    if (window.XMLHttpRequest) {
	        self.xmlHttpReq = new XMLHttpRequest();
	    }
	    // IE
	    else if (window.ActiveXObject) {
	        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	    }
	    self.xmlHttpReq.open('POST', strURL, true);
	    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	    self.xmlHttpReq.onreadystatechange = function() {
	        if (self.xmlHttpReq.readyState == 4) {
	            successFunc(self.xmlHttpReq.responseText);
	        }
	    };
	    self.xmlHttpReq.send(inputArgs);
	}

	function dateChanged(newDate) {
		var dt = newDate.toString() ;
		var ff = function (response) {
			//alert('Server sent: ' + response);
			var responseStr = "" + response;
			if(responseStr.substring(0,5) == "ERROR") {
				alert(responseStr);
				document.getElementById("wreceiptStart").innerHTML = "N/A";
				document.getElementById("wreceiptEnd").innerHTML = "N/A";
				document.getElementById("wreceiptTotal").value = "0";
				return;
			}
			if(responseStr.substring(0,9) == "EXCEPTION") {
				document.getElementById("wreceiptStart").innerHTML = "N/A";
				document.getElementById("wreceiptEnd").innerHTML = "N/A";
				document.getElementById("wreceiptTotal").value = "0";
				return;
			}
			var strs = responseStr.split(",");			
			
			document.getElementById("wreceiptStart").innerHTML = strs[0];
			document.getElementById("wreceiptEnd").innerHTML = strs[1];
			document.getElementById("wreceiptTotal").value = strs[2];
			sumAll();
			
		};
		ajaxGet('/BSS/ReceiptRevenue', 'Date='+dt, ff );
	
	}

	function sumAll() {

		document.getElementById('col12b').value = 	parseInt(document.getElementById('col1a').value) 
		+ parseInt(document.getElementById('col2a').value);

		document.getElementById('col910c').value = 	parseInt(document.getElementById('col9b').value) 
		+ parseInt(document.getElementById('col10b').value);
		
		document.getElementById('col5678b').value = parseInt(document.getElementById("col5a").value) 
		+ parseInt(document.getElementById('col6a').value)
		+ parseInt(document.getElementById('col7a').value)
		+ parseInt(document.getElementById('col8a').value);
		
		document.getElementById('colTotal').value = parseInt(document.getElementById('col12b').value) 
		+ parseInt(document.getElementById('col5678b').value)
		+ parseInt(document.getElementById('wreceiptTotal').value)
		+ parseInt(document.getElementById('col910c').value)
		+ parseInt(document.getElementById('col11a').value) 
		+ parseInt(document.getElementById('col12a').value);
	}

	function validateInteger(inputObject,flag,message)
	{		
		var re = /[^0-9]/;
		if (re.exec(inputObject.value))
		{			
			if(flag)
				alert(message);
			inputObject.value = "0";
			sumAll();
		}
	}
	
</script>


</head>
<%
    	session.setAttribute("Event","PaymentCommand");
    	session.setAttribute("action", 6);
    	String errMsg="";
    	
    	if(session.getAttribute("Error")!=null)
    	{
    		 errMsg=session.getAttribute("Error").toString();
    		 session.removeAttribute("Error");
    	}
    	
    	DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm aaa");
    	java.util.Date date = new java.util.Date();
    	String datetime = dateFormat.format(date);
    	Calendar cal = Calendar.getInstance();
    	cal.add(Calendar.DATE, 7);
    	String newdate = dateFormat.format(cal.getTime());

    	DailyRevenue revenue =(DailyRevenue)session.getAttribute("todaysRevenue");
    	
    %>
<body>
	<table>
		<tr>
				<td colspan="2">
					<font color="red" ><%= errMsg%></font>
				</td>
			</tr>
	</table>
	<a href="/BSS/reports.jsp">Back to Reports</a>
	<form action="/BSS/BSSServlet" name="login" method="post" >
	<table align="center">
		<tr style=" height : 52px;">
			<td valign="top" align="center" style="font-family: sans-serif; text-decoration: underline;">
				<h4>DAILY REVENUE</h4>
			</td>
		</tr>
		<tr>
			<td>
				<table border=1 align="center" style="font-family: sans-serif; font-size: small;">
					<tr style=" height : 42px;">
						<td colspan="5" align="right" valign="top">
							Date: <%=revenue.getDateGenerated() %>								
						</td>					
					</tr>
					<tr>
						<td align="center">
							S.No.
						</td>
						<td colspan="3" align="center">
							Collection
						</td>
						<td align="center">
							Rs.
						</td>
					</tr>
					<tr>
						<td align="center">
							1
						</td>
						<td colspan="2">
							Rasoi Morning
						</td>
						<td colspan="1" style=" width : 68px;">
							<%=revenue.getRasoiMorning() %>
						</td>
						<td colspan="1" rowspan="2" style=" width : 73px;" align="right">
							<%=revenue.getRasoiMorning() + revenue.getRasoiEvening() %>
						</td>
					</tr>
					<tr>
						<td align="center" >
							2
						</td>
						<td colspan="2">
							Rasoi Evening
						</td>
						<td colspan="1">
							<%=revenue.getRasoiEvening() %>
						</td>
					</tr>
					<tr>
						<td align="center">
							3
						</td>
						<td colspan="1">
							W recpt
						</td>
						<td colspan="1" style=" width : 68px;" align="right">
							<%=revenue.getwReceiptStart() %>
						</td>
						<td colspan="1" align="right">
							<%=revenue.getwReceiptEnd() %>
						</td>
						<td colspan="1" rowspan="2" align="right">
							<%=revenue.getReceiptTotal() %>
						</td>
					</tr>
					<tr>
						<td align="center">
							4
						</td>
						<td colspan="1">
							W recpt
						</td>
						<td colspan="1">
							-
						</td>
						<td colspan="1">
							-
						</td>
					</tr>
					<tr>
						<td align="center">
							5
						</td>
						<td colspan="2">
							Bus Morning
						</td>
						<td colspan="1">
							<%=revenue.getBusMorning() %>
						</td>
						<td colspan="1" rowspan="4" align="right">
							<%=revenue.getBusMorning() + revenue.getBusAfternoon() + revenue.getBusEvening() + revenue.getBusMini() %>
						</td>
					</tr>
					<tr>
						<td align="center" >
							6
						</td>
						<td colspan="2">
							Bus Afternoon
						</td>
						<td colspan="1">
							<%=revenue.getBusAfternoon() %>
						</td>
					</tr>
					<tr>
						<td align="center" >
							7
						</td>
						<td colspan="2">
							Bus Mini
						</td>
						<td colspan="1">
							<%=revenue.getBusMini() %>
						</td>
					</tr>
					<tr>
						<td align="center" >
							8
						</td>
						<td colspan="2">
							Bus Evening
						</td>
						<td colspan="1">
							<%=revenue.getBusEvening() %>
						</td>
					</tr>
					<tr>
						<td align="center">
							9
						</td>
						<td colspan="1">
							Ambulance
						</td>
						<td colspan="1">
							<%=revenue.getAmbulanceDetail1() %>
						</td>
						<td colspan="1" align="right">
							<%=revenue.getAmbulanceRevenue1() %>
						</td>
						<td colspan="1" rowspan="2" align="right">
							<%=revenue.getAmbulanceRevenue1() + revenue.getAmbulanceRevenue2() %>
						</td>
					</tr>
					<tr>
						<td align="center">
							10
						</td>
						<td colspan="1">
							Ambulance
						</td>
						<td colspan="1">
							<%=revenue.getAmbulanceDetail2() %>
						</td>
						<td colspan="1" align="right">
							<%=revenue.getAmbulanceRevenue2() %>
						</td>
					</tr>
					<tr>
						<td align="center">
							11
						</td>
						<td colspan="3">
							Others(<%=revenue.getOthersDetail1() %>)
						</td>
						<td colspan="1" align="right">
							<%=revenue.getOthersRevenue1() %>
						</td>
					</tr>
					<tr>
						<td align="center">
							12
						</td>
						<td colspan="3">
							Others(<%=revenue.getOthersDetail2() %>)
						</td>
						<td colspan="1" align="right">
							<%=revenue.getOthersRevenue2() %>
						</td>
					</tr>
					
					<tr>
						<td colspan="4" align="right">
							Total
						</td>
						<td colspan="1" rowspan="1" align="right">
							<%=revenue.getRasoiMorning() + revenue.getRasoiEvening() + revenue.getReceiptTotal() + revenue.getBusMorning() +
								revenue.getBusAfternoon() + revenue.getBusEvening() + revenue.getBusMini() + revenue.getAmbulanceRevenue1() +
								revenue.getAmbulanceRevenue2() + revenue.getOthersRevenue1() + revenue.getOthersRevenue2() %>
						</td>
					</tr>
				</table>			
			</td>				
		</tr>		
	</table>	
	</form>
</body>
</html>